<?php

namespace app\admin\model;

use think\Model;


class Stuff extends Model
{

    

    

    // 表名
    protected $name = 'stuff';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'statuslist_text'
    ];
    

    
    public function getStatuslistList()
    {
        return ['正常' => __('正常'), '过期' => __('过期'), '扔掉' => __('扔掉'), '售卖中' => __('售卖中'), '已卖' => __('已卖')];
    }


    public function getStatuslistTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['statuslist']) ? $data['statuslist'] : '');
        $list = $this->getStatuslistList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function level()
    {

        // return $this->belongsTo('Level', 'level_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
